<?php


namespace app\admin\model;


use think\Model;

class Forms extends Model
{
   public function getlist()
   {
       return $this->with('foods','users')->where('check','=',1)
       ->group('form_number')->order('ftime desc')->paginate('5');
   }
    public function foods(){
        return $this->belongsTo('Foods','fid');

    }
    public function users(){
        return $this->belongsTo('Users','uid');

    }


   public function getFdetails($no)
   {
       return $this->with('foods','users')->where('form_number',$no)->find();
   }
    public function getDe($no)
    {
        return $this->with('foods','users')->where('form_number',$no)->select();
    }

   public function getNforms()
   {
       return $this->with('users')->where('check','=',2)->group('form_number')->paginate(5);
   }
   public function updateCode($code,$no){
       return $this->isUpdate(true)->save([
           'code'  => $code,
           'check' => 1
       ],['id' => $no]);
   }
public function delOrder($no)
{
    return $this->where('id',$no)->delete();
}
}